# coding=utf-8
#!/usr/bin/python3
import json

import execjs
import requests

cookies = {
    'wd_guid': '6f004b50-2efa-4b02-83e5-7c68e5c9e64f',
    'historyState': 'state',
    '__c': '1724480032',
    '__g': '-',
    '__l': 'l=%2Fwww.kanzhun.com%2F&r=',
    'Hm_lvt_1f6f005d03f3c4d854faec87a0bee48e': '1724466676,1724475888,1724480033',
    'HMACCOUNT': 'ED0735D1CE0FB96D',
    '__a': '11718226.1724466674.1724475888.1724480032.11.3.5.11',
    'Hm_lpvt_1f6f005d03f3c4d854faec87a0bee48e': '1724481619',
}

headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
    # 'cookie': 'wd_guid=6f004b50-2efa-4b02-83e5-7c68e5c9e64f; historyState=state; __c=1724480032; __g=-; __l=l=%2Fwww.kanzhun.com%2F&r=; Hm_lvt_1f6f005d03f3c4d854faec87a0bee48e=1724466676,1724475888,1724480033; HMACCOUNT=ED0735D1CE0FB96D; __a=11718226.1724466674.1724475888.1724480032.11.3.5.11; Hm_lpvt_1f6f005d03f3c4d854faec87a0bee48e=1724481619',
    'href': 'https://www.kanzhun.com/search?cityCode=101110100&experienceId=&pageNum=1&query=python&salaryId=&type=5',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://www.kanzhun.com/search?cityCode=101110100&experienceId=&pageNum=1&query=python&salaryId=&type=5',
    'reqsource': 'fe',
    'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'traceid': 'F-67a864YSYtD00M8Q',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
    'x-requested-with': 'XMLHttpRequest',
}



js_compile=execjs.compile(open("./01kanzhun.js",encoding='utf-8').read())
n={"query":"python","cityCode":101180100,"salaryId":"","experienceId":"","pageNum":1,"limit":150}
data=json.dumps(n)
js_data=js_compile.call("enc",data)
params = {
    'b': js_data[0],
    'kiv': js_data[1],
}

response = requests.get('https://www.kanzhun.com/api_to/search/job.json', params=params, cookies=cookies, headers=headers).text
answer=js_compile.call("decrypt",response,js_data[1])
print(answer)